import React from 'react';
import { history } from 'umi'
import { Table } from 'antd';
import moment from 'moment';
import { Icon } from '@/pages/Recruitment/components';

const ArrangeTable = ({ dataSource = [] }) => {
    const columns = [
        {
            title: '名称',
            dataIndex: 'interviewTitle'
        },
        {
            title: '类型',
            dataIndex: 'interviewTypeName'
        },
        {
            title: '日期',
            dataIndex: 'interviewStartTime',
            render: text => (text ? moment(text).format('YYYY/MM/DD') : '')
        },
        {
            title: '结论',
            dataIndex: 'resultTypeName',
            render: text => {
                let color = '';
                switch (text) {
                    case '需观察':
                        color = '#F5222D';
                        break;
                    case '继续试用':
                        color = '#5590F6';
                        break;
                    default:
                        break;
                }
                return color ? <span style={{ color }}>{text}</span> : text;
            }
        },
        {
            title: '面谈总结',
            ellipsis: true,
            dataIndex: 'resultContent'
        },
        {
            title: '操作',
            dataIndex: 'operation',
            align: 'center',
            width: 100,
            render: (text, row) => (
                <Icon
                    title="查看详情"
                    type="chakanxiangqing"
                    onClick={() => {
                        history.push({
                            pathname: '/office/personnelManagement/onboardAndLeave/informal/process/detail',
                            query: { id: row?.id || '' },
                            state: { tabRoute: true, tabRefresh: true }
                        });
                    }}
                />
            )
        }
    ];

    return (
        <Table
            rowKey="id"
            bordered
            dataSource={dataSource}
            columns={columns}
            pagination={false}
            scroll={{ x: 'max-content' }}
        />
    );
};

export default ArrangeTable;
